﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MakeIT_Bill_Maker
{
    public partial class AddAppartment : Form
    {
        public AddAppartment()
        {
            InitializeComponent();
        }

        // Cancel Button
        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        // Add Button
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string sql = "";
            string name = txtname.Text;
            string apptno = txtapptno.Text;
            string meterno = txtmeterno.Text;
            string arrears = txtarrears.Text;

            sql = "INSERT INTO Users  (`AptNo`, `Name`, `MeterNo`, `Arrears`) VALUES ('" + apptno + "','" + name + "','" + meterno + "','" + arrears + "')";
            Database.DatabaseConnection db = new Database.DatabaseConnection();
            Boolean b = db.add(sql);

            // Condition
            if (b == true)
            {
                MessageBox.Show("Record is added succesfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Failed to add new Record.", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
    }
    }
}
